<?php


namespace app\admin\model;


use app\common\model\BaseModel;

class ImportErrLog extends BaseModel {

    /**
     * 失败详情
     * @param $params
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\ModelNotFoundException
     * @throws \think\exception\DbException
     */
    public static function errInfo($params) {
        $count = self::where('import_id', $params['id'])
            ->count();
        if ($count == 0) {
            $result = [
                'page'    => 1,
                'pageNum' => 1,
                'count'   => 0,
                'data'    => [],
            ];
        } else {
            $data = self::where('import_id', $params['id'])
                ->field('msg,house_id')
                ->page($params['page'], $params['long'])
                ->order('id desc')
                ->select()
                ->toArray();
            $pageNum = ceil($count / $params['long']);
            $result = [
                'page'    => (int)$params['page'],
                'pageNum' => $pageNum,
                'count'   => $count,
                'data'    => $data,
            ];
        }
        return $result;
    }


}